public class Elevator {
    private int currentFloor = 1;
    private int minFloor;
    private int maxFloor;

    public Elevator(int minFloor, int maxFloor) {
        this.minFloor = minFloor;
        this.maxFloor = maxFloor;

        if (currentFloor < minFloor) {
            currentFloor = minFloor;
        } else if (currentFloor > maxFloor) {
            currentFloor = maxFloor;
        }
    }

    public int getCurrentFloor() {
        return currentFloor;
    }

    public void moveDown() {
        if (currentFloor > minFloor) {
            currentFloor = currentFloor - 1;

            // No zero floor in elevator
            if (currentFloor == 0) {
                moveDown();
            }
        }
    }

    public void moveUp() {
        if (currentFloor < maxFloor) {
            currentFloor = currentFloor + 1;

            // No zero floor in elevator
            if (currentFloor == 0) {
                moveUp();
            }
        }
    }

    public void move(int floor) {
        if (floor > maxFloor || floor < minFloor || floor == 0) {
            System.out.println("Этаж задан неверно!");
            return;
        }

        while (floor != currentFloor) {
            if (floor > currentFloor) {
                moveUp();
            } else {
                moveDown();
            }

            System.out.println(currentFloor);
        }
    }
}
